package com.lzh.demo;


import java.util.*;

/**
 * @author liuzhihao
 * @create 2022-01-19 21:19
 */
public class demo1 {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String no = scanner.nextLine();
        List<Integer> oneN = new ArrayList();
        List<Integer> twoY = new ArrayList();


        String[] s = no.split(" ");
        if (s.length < 999) {
            Map<Integer, String> map = new HashMap<>();
            for (String temp : s) {
                String[] split = temp.split("/");
                if (Integer.parseInt(split[0]) < 0 || Integer.parseInt(split[0]) >= 999) {
                    System.out.println("ERROR");
                    break;
                } else {
                    map.put(Integer.parseInt(split[0]), split[1]);
                }
            }

            Set<Map.Entry<Integer, String>> entrySet = map.entrySet();
            for (Map.Entry<Integer,String> set : entrySet) {
                if ("N".equals(set.getValue())) {
                    oneN.add(set.getKey());
                }
                if ("Y".equals(set.getValue())){
                    twoY.add(set.getKey());
                    twoY.add(set.getKey() - 1);
                }
            }

            for (Integer m : oneN) {
                twoY.remove(m);
            }

            Collections.sort(oneN);
            Collections.sort(twoY);

            if (oneN.get(0) > twoY.get(0)) {
                print(twoY);
                print(oneN);
            } else {
                print(oneN);
                print(twoY);
            }
        } else {
            System.out.println("ERROR");
        }
    }

    public static void print(List<Integer> list) {
        for (Integer temp : list) {
            System.out.print(temp+ " ");
        }
        System.out.println();
    }

}
